package com.cate.controller.admin;

import com.cate.pojo.vo.BusinessDataVO;
import com.cate.pojo.vo.DishOverViewVO;
import com.cate.pojo.vo.OrderOverViewVO;
import com.cate.pojo.vo.SetmealOverViewVO;
import com.cate.result.RestResponse;
import com.cate.service.WorkspaceService;
import com.cate.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @CreateTime: 2023/8/2
 * @Author: <==lhd==>
 * @Description:
 */

@RestController
@Slf4j
@RequestMapping("/admin/workspace")
@Api(tags = "工作台管理")
public class WorkspaceController {
    @Autowired
    private WorkspaceService workspaceService;

    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public RestResponse<SetmealOverViewVO> overviewSetmeals(){
        return ResultUtil.success(workspaceService.getSetmealOverView());
    }

    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public RestResponse<DishOverViewVO> overviewDishes(){
        return ResultUtil.success(workspaceService.getDishOverView());
    }

    @GetMapping("/businessData")
    @ApiOperation("查询今日运营数据")
    public RestResponse<BusinessDataVO> getBusinessData(){
        //获得当天的开始时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        //获得当天的结束时间
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin, end);
        return ResultUtil.success(businessDataVO);
    }

    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单管理数据")
    public RestResponse<OrderOverViewVO> overviewOrders(){
        return ResultUtil.success(workspaceService.getOrderOverView());
    }

}
